<template>
	<view :style="colorStyle">
		<view class='merchantList'>
			<view class='list'>
				<block v-for="(item,index) in merchantList" :key="index">
					<navigator :url="'/pages/merchant/index?mer_id=' + item.id" hover-class='none' class='item acea-row row-between-wrapper'>
						<view class='pictrue'>
							<image :src='item.avatar'></image>
						</view>
						<view class='text acea-row'>
							<view class='name line2'>{{item.merchant_name}}</view>
							<view>地址：{{item.address}}</view>
						</view>
					</navigator>
				</block>
			</view>
		</view>
		<view class='noCommodity' v-if="merchantList.length == 0 && (page != 1 || active== 0)">
			<view class='pictrue'>
				<image src='https://fuli-cloud.brdhrm.com/static/images/empty-box.png'></image>
			</view>
		</view>
		<!-- #ifndef MP -->
		<home></home>
		<!-- #endif -->
	</view>
</template>

<script>
	import {
		getMerchantList
	} from '@/api/merchant.js';
	import home from '@/components/home';
	import colors from "@/mixins/color";
	export default {
		components: {
			home
		},
		mixins: [colors],
		data() {
			return {
				merchantList: [],
				navList: [],
				active: 0,
				page: 1,
				limit: 10,
				status: false,
			};
		},
		/**
		 * 生命周期函数--监听页面显示
		 */
		onShow: function() {
			this.getMerchantList(1);
			this.status = false;
			this.page = 1;
			this.merchantList = [];
		},
		/**
		 * 页面上拉触底事件的处理函数
		 */
		onReachBottom: function() {
			this.getMerchantList(1);
		},
		methods: {
			//获取商户列表
			getMerchantList(type) {
				let that = this;
				let limit = that.limit;
				let page = that.page;
				let merchantList = that.merchantList;
				if (that.status) return;
				getMerchantList(type, {
					page: page,
					limit: limit
				}).then(res => {
					let merchantListNew = [];
					let len = res.length;
					merchantListNew = merchantList.concat(res.data.list);
					that.page++;
					that.$set(that, 'merchantList', merchantListNew);
					that.status = limit > len;
					that.page = that.page;
				});
			},
			getArticleCate() {
				let that = this;
				getArticleCategoryList().then(res => {
					that.$set(that, 'navList', res.data);
				});
			},
		}
	}
</script>

<style lang="scss">
	.noCommodity {
		border-top-width: 0;
	}

	page {
		background-color: #fff !important;
	}

	.merchantList .list {
		margin-top: 20rpx;
	}

	.merchantList .list .item {
		margin: 0 30rpx;
		border-bottom: 1rpx solid #f0f0f0;
		padding: 35rpx 0;
	}

	.merchantList .list .item .pictrue {
		width: 150rpx;
		height: 150rpx;
	}

	.merchantList .list .item .pictrue image {
		width: 100%;
		height: 100%;
		border-radius: 6rpx;
	}

	.merchantList .list .item .text {
		width: 480rpx;
		height: 156rpx;
		font-size: 24rpx;
		color: #999;
	}

	.merchantList .list .item .text .name {
		font-size: 33rpx;
		color: #282828;
		margin-top: 8px;
	}

	.merchantList .list .item .time {
		text-align: right;
		font-size: 24rpx;
		color: #999;
		margin-top: 22rpx;
	}
</style>
